﻿<!--#include file="const.inc"-->
<%
'====================================================================
' 感谢使用晴天3G智能建站系统..
' 作者:梁永强.QQ:766750857
' 官方网址:wap.qt3g.com
' 声明:软件版权归作者所有,没有经过作者本人同意不得非法破解和传播本程序
'====================================================================
%>
<%

	dim rs,sql,listid,id,pageid,voteid,name
		listid=Request.QueryString("listid")
		if not isnumeric(listid) then listid=0
		if listid="" then listid=0
		listid=clng(listid)

		id=Request.QueryString("id")
		if not isnumeric(id) then id=0
		if id="" then id=0
		id=clng(id)


		pageid=Request.QueryString("pageid")
		if not isnumeric(pageid) then pageid=0
		if pageid="" then pageid=0
		pageid=clng(pageid)



		voteid=Request.form("voteid")
		if not isnumeric(voteid) then voteid=0
		if voteid="" then voteid=0
		voteid=clng(voteid)
		Set Rs = Server.CreateObject("Adodb.Recordset")
select case v
case "0"
we0="<br/>"
%>
<card title="投票"><p align="<%=qingtian.px%>">
<%
case "1"
hr=""
zi="<span style=""color:#FF5500"">"
zi0="</span>"
we="<div class=""footer"">"
sou="<div class=""block4"">"
dao="<div class=""navi"">"
we0="</div>"
%>
<title>投票</title>
</head>
<body>
<!--#include virtual="/css.inc"-->
<%

End Select

		if sid="Null" then
		%><%=dao%><%=zi%>欢迎你<%=zi0%><a href="/login.asp?sid=<%=sidd%>&amp;url=/bbs/vo.asp?id=<%=id%>@@listid=<%=listid%>@@voteid=<%=voteid%>@@backurl=<%=Replace(backurl,"@@","@*@")%>">注册/登陆</a><%=we0%><%=we%>请先登陆再投票<%=we0%><%
		else


		Sql = "select top 1 [vote],[votenum],[votenid],[votetype],[nid] from [qingtian_bbs_forum] where [del]=0 and [listid]="&listid&" and [id]="&id
			Rs.Open Sql,conn,1,1
			if not (rs.bof and rs.eof)  then
			if rs("vote")<>"" then
				dim votenum,vote,votenum_1,i
				votenum=split(rs("votenum"),"|")
				vote=false
            			For i = 0 to ubound(votenum)

					if cint(voteid)=i then
					votenum(i)=votenum(i)+1
					end if

					if votenum_1="" then
					votenum_1=votenum(i)
					else
					votenum_1=votenum_1 & "|" & votenum(i)
					end if
            			Next

					dim nid,votenid,rs2,votenid_1,sql2



					Sql2 = "select [id] FROM qingtian_user where [sid]='"&md5(sid) & md5(strReverse(sid))&"'"
					Set Rs2 = Server.CreateObject("Adodb.Recordset")
					Rs2.Open Sql2,conn,1,1
					if not (rs2.eof and rs2.bof) then
						nid=rs2("id")
					else
						nid=0
					end if
					Rs2.close
					set rs2=nothing


				if rs("votenid")<>"" then
					votenid=split(rs("votenid"),"|")
            				For i = 0 to ubound(votenid)
               					If clng(votenid(i)) = nid Then
							vote=true
							exit for
                				End If
            				Next
				end if

				if vote=true then
					if rs("votetype")=true then
						vote=false
					else
						%><%=we%>你已经投票过了，请不要重复投票!<%=we0%><%
					end if
				else
					if rs("votenid")<>"" then
					votenid_1=rs("votenid") & "|" & nid
					else
					votenid_1= nid
					end if
				end if


				if vote=false then
				Set Rs2 = Server.CreateObject("Adodb.Recordset")
				Sql2 = "SELECT [votenum],[votenid]  FROM [qingtian_bbs_forum] where [del]=0 and [id]="&id&" and listid="&listid
				Rs2.Open Sql2,conn,1,3
				if not (rs2.bof and rs2.eof)  then
					rs2("votenum")=votenum_1
					rs2("votenid")=votenid_1
					rs2.update
				end if
				Rs2.close
					%><%=we%>投票成功!<%=we0%><%
				end if
				set rs2=nothing

			end if
			end if
			Rs.close
		end if


	Sql = "SELECT [name]  FROM [qingtian_bbs] where [del]=0 and [id]="&listid
	Rs.Open Sql,conn,1,1
	if not (rs.bof and rs.eof)  then
		name=qingtian.utf8(rs("name"))
	end if
	Rs.close

	set rs=nothing


%>
<%=qingtian.qingsav("74")%><%=sou%><a href="viewv.asp?id=<%=id%>&amp;listid=<%=listid%>&amp;pageid=<%=pageid%>&amp;sid=<%=sidd%>">返回帖子</a><br/>
<a href="board.asp?listid=<%=listid%>&amp;sid=<%=sidd%>"><%=name%>论坛</a><%=we0%>
<%
End Function
%>
